package com.obrempon.credit.market.ui.adapter

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.obrempon.credit.market.ObremponApp
import com.obrempon.credit.market.R
import com.obrempon.module.adapter.ObremponRecyclerViewAdapter
import com.obrempon.module.adapter.ObremponViewHolderHelper
import com.obrempon.module.shapeview.layout.ShapeConstraintLayout
import org.json.JSONObject

/**
 * ObremponCredit
 * @Author wwdeng
 * @CreateTime: 2025/3/10 20:14
 * @Annotation：进件信息 - 证件照类型 Popupwindow item
 */
class ObremponAuthStepOcrTypePopuApt(recyclerView: RecyclerView?) : ObremponRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.obrempon_auth_step_ocr_type_popupwindow_item) {
    override fun setItemChildListener(helper: ObremponViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.itemLayout) //点击Item
    }
    override fun fillData(helper: ObremponViewHolderHelper, position: Int, model: JSONObject) {
        val imgOcrTypeIcon = helper.getImageView(R.id.imgOcrTypeIcon)
        imgOcrTypeIcon.setImageResource(model.optInt("iconId"))

        val textOcrTypeTitle = helper.getTextView(R.id.textOcrTypeTitle)
        textOcrTypeTitle.text = model.optString("title")

        val itemLayout = helper.getView<ShapeConstraintLayout>(R.id.itemLayout)
        if (model.optBoolean("isSelect",false)) {
            helper.setVisibility(R.id.imgOcrTypeSelected, View.VISIBLE)
//            if (position == itemCount - 1){
//                itemLayout.shapeDrawableBuilder
//                    .setSolidColor(getColor(R.color.color_ffe5f1ff))
//                    .setBottomLeftRadius(ObremponApp.app.resources.getDimension(com.obrempon.module.R.dimen.dp_12))
//                    .setBottomRightRadius(ObremponApp.app.resources.getDimension(com.obrempon.module.R.dimen.dp_12))
//                    .intoBackground()
//            } else {
//                itemLayout.shapeDrawableBuilder
//                    .setSolidColor(getColor(R.color.color_ffe5f1ff))
//                    .setBottomLeftRadius(ObremponApp.app.resources.getDimension(com.obrempon.module.R.dimen.dp_0))
//                    .setBottomRightRadius(ObremponApp.app.resources.getDimension(com.obrempon.module.R.dimen.dp_0))
//                    .intoBackground()
//            }
        } else {
            helper.setVisibility(R.id.imgOcrTypeSelected, View.INVISIBLE)
//            itemLayout.shapeDrawableBuilder.setSolidColor(getColor(R.color.transparent)).intoBackground()
        }
        if (position == itemCount - 1){
            helper.setVisibility(R.id.viewLine, View.INVISIBLE)
        } else {
            helper.setVisibility(R.id.viewLine, View.VISIBLE)
        }
    }
}